<template>
  <div class="reportFormPage" v-if="show">
    <div class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">{{ this.form.baobmc }}</div>
        <div class="codeText">
          <tr v-for="(item, index) in form.baobbhList">
            {{
              item
            }}
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span class="placeholder">{{ form.jilbh }}</span>
        </div>
      </div>
      <!-- .........................1111111111111111111111111111111......................................................... -->
      <div class="table-border">
        <table height="220px" class="top-table">
          <tbody>
            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcmc }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="50" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；样品数量：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ placeholder: !form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
            </tr>
            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>
              <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->
              <td width="35%" class="text-center">
                <el-input v-model="form.shiyjcrq" />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" class="height100" style="width: 15%" />
                ℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" class="height100" style="width: 15%" />
                %RH
              </td>
            </tr>
            <tr>
              <td height="50" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="50" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <!-- 616px -->
        <table height="120px" class="middle-table">
          <tbody>
            <tr height="30">
              <td colspan="1" width="15%">样品缩分方法</td>
              <td colspan="10">
                <!-- <el-input v-model="form.yangpsfff" /> -->
                <el-select clearable v-model="form.yangpsfff" class="hide-icon width100 height100" placeholder>
                  <el-option label="分料器法" value="分料器法"></el-option>
                  <el-option label="分铲法" value="分铲法"></el-option>
                  <el-option label="四分法" value="四分法"></el-option>
                </el-select>
              </td>
            </tr>
            <tr height="30">
              <td rowspan="3" colspan="1" width="15%">试样质量(g)</td>
              <td colspan="4" style="width: calc(60% / 2)">第1组</td>
              <td colspan="4" style="width: calc(60% / 2)">第2组</td>
              <td rowspan="3" colspan="2" width="15%">平均</td>
            </tr>
            <tr height="30">
              <td colspan="1" style="width: calc(60% / 6)">第一次称重</td>
              <td colspan="1" style="width: calc(60% / 6)">第二次称重</td>
              <td colspan="2" style="width: calc(60% / 6)">第三次称重</td>
              <td colspan="1" style="width: calc(60% / 6)">第一次称重</td>
              <td colspan="1" style="width: calc(60% / 6)">第二次称重</td>
              <td colspan="2" style="width: calc(60% / 6)">第三次称重</td>
            </tr>
            <tr height="30">
              <td colspan="1"><el-input v-model="form.chengz11" /></td>
              <td colspan="1"><el-input v-model="form.chengz12" /></td>
              <td colspan="2"><el-input v-model="form.chengz13" /></td>
              <td colspan="1"><el-input v-model="form.chengz21" /></td>
              <td colspan="1"><el-input v-model="form.chengz22" /></td>
              <td colspan="2"><el-input v-model="form.chengz23" /></td>
            </tr>
          </tbody>
        </table>
        <table height="495px" class="middle-table">
          <tbody>
            <tr height="30">
              <td colspan="1" width="15%">筛孔尺寸(mm)</td>
              <td colspan="1" style="width: calc(60% / 8)">筛上重(g)</td>
              <td colspan="1" style="width: calc(60% / 8)">分计筛余(%)</td>
              <td colspan="1" style="width: calc(60% / 8)">累计筛余(%)</td>
              <td colspan="1" style="width: calc(60% / 8)">通过百分率(%)</td>
              <td colspan="1" style="width: calc(60% / 8)">筛上重(g)</td>
              <td colspan="1" style="width: calc(60% / 8)">分计筛余(%)</td>
              <td colspan="1" style="width: calc(60% / 8)">累计筛余(%)</td>
              <td colspan="1" style="width: calc(60% / 8)">通过百分率(%)</td>
              <td colspan="1" width="7.5%">通过百分率(%)</td>
              <td colspan="1" width="7.5%">筛余率(%)</td>
            </tr>
            <tr height="50">
              <td colspan="1" width="15%">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shaikccItem1" @keydown.native="handleKeyDown($event, 2, 0)" @paste.native="handlePasteThree($event, 0, 0)" :ref="'2_0'" />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  v-model="form.shaiszGroup1Item1"
                  @change="computeFjsy1(1, 1)"
                  @keydown.native="handleKeyDown($event, 2, 1)"
                  @paste.native="handlePasteThree($event, 0, 1)"
                  :ref="'2_1'"
                />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.fenjsyGroup1Item1 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.leijsyGroup1Item1 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.tonggbflGroup1Item1 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  v-model="form.shaiszGroup2Item1"
                  @change="computeFjsy1(2, 1)"
                  @keydown.native="handleKeyDown($event, 2, 2)"
                  @paste.native="handlePasteThree($event, 0, 2)"
                  :ref="'2_2'"
                />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.fenjsyGroup2Item1 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.leijsyGroup2Item1 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.tonggbflGroup2Item1 }}</td>
              <td colspan="1" width="7.5%">{{ form.tonggbflPjzItem1 }}</td>
              <td colspan="1" width="7.5%">{{ form.shaiyl1 }}</td>
            </tr>
            <tr height="50">
              <td colspan="1" width="15%">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shaikccItem2" @keydown.native="handleKeyDown($event, 3, 0)" @paste.native="handlePasteThree($event, 1, 0)" :ref="'3_0'" />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  v-model="form.shaiszGroup1Item2"
                  @change="computeFjsy2(1, 2)"
                  @keydown.native="handleKeyDown($event, 3, 1)"
                  @paste.native="handlePasteThree($event, 1, 1)"
                  :ref="'3_1'"
                />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.fenjsyGroup1Item2 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.leijsyGroup1Item2 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.tonggbflGroup1Item2 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  v-model="form.shaiszGroup2Item2"
                  @change="computeFjsy2(2, 2)"
                  @keydown.native="handleKeyDown($event, 3, 2)"
                  @paste.native="handlePasteThree($event, 1, 2)"
                  :ref="'3_2'"
                />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.fenjsyGroup2Item2 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.leijsyGroup2Item2 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.tonggbflGroup2Item2 }}</td>
              <td colspan="1" width="7.5%">{{ form.tonggbflPjzItem2 }}</td>
              <td colspan="1" width="7.5%">{{ form.shaiyl2 }}</td>
            </tr>
            <tr height="50">
              <td colspan="1" width="15%">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shaikccItem3" @keydown.native="handleKeyDown($event, 4, 0)" @paste.native="handlePasteThree($event, 2, 0)" :ref="'4_0'" />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  v-model="form.shaiszGroup1Item3"
                  @change="computeFjsy3(1, 3)"
                  @keydown.native="handleKeyDown($event, 4, 1)"
                  @paste.native="handlePasteThree($event, 2, 1)"
                  :ref="'4_1'"
                />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.fenjsyGroup1Item3 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.leijsyGroup1Item3 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.tonggbflGroup1Item3 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  v-model="form.shaiszGroup2Item3"
                  @change="computeFjsy3(2, 3)"
                  @keydown.native="handleKeyDown($event, 4, 2)"
                  @paste.native="handlePasteThree($event, 2, 2)"
                  :ref="'4_2'"
                />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.fenjsyGroup2Item3 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.leijsyGroup2Item3 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.tonggbflGroup2Item3 }}</td>
              <td colspan="1" width="7.5%">{{ form.tonggbflPjzItem3 }}</td>
              <td colspan="1" width="7.5%">{{ form.shaiyl3 }}</td>
            </tr>
            <tr height="50">
              <td colspan="1" width="15%">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shaikccItem4" @keydown.native="handleKeyDown($event, 5, 0)" @paste.native="handlePasteThree($event, 3, 0)" :ref="'5_0'" />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  v-model="form.shaiszGroup1Item4"
                  @change="computeFjsy4(1, 4)"
                  @keydown.native="handleKeyDown($event, 5, 1)"
                  @paste.native="handlePasteThree($event, 3, 1)"
                  :ref="'5_1'"
                />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.fenjsyGroup1Item4 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.leijsyGroup1Item4 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.tonggbflGroup1Item4 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  v-model="form.shaiszGroup2Item4"
                  @change="computeFjsy4(2, 4)"
                  @keydown.native="handleKeyDown($event, 5, 2)"
                  @paste.native="handlePasteThree($event, 3, 2)"
                  :ref="'5_2'"
                />
              </td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.fenjsyGroup2Item4 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.leijsyGroup2Item4 }}</td>
              <td colspan="1" style="width: calc(60% / 8)">{{ form.tonggbflGroup2Item4 }}</td>
              <td colspan="1" width="7.5%">{{ form.tonggbflPjzItem4 }}</td>
              <td colspan="1" width="7.5%">{{ form.shaiyl4 }}</td>
            </tr>

            <!--                    <tr height="50">-->
            <!--                        <td colspan="1" width="10%">-->
            <!--                            <el-input :type="isPdf ? 'string' : 'number'"-->
            <!--                                      v-model="form.shaikccItem5"-->
            <!--                                      @keydown.native="handleKeyDown($event, 6, 0)"-->
            <!--                                      @paste.native="handlePasteThree($event, 4, 0)"-->
            <!--                                      :ref="'6_0'"/>-->
            <!--                        </td>-->
            <!--                        <td colspan="1" width="10%">-->
            <!--                            <el-input :type="isPdf ? 'string' : 'number'"-->
            <!--                                      v-model="form.shaiszGroup1Item5"-->
            <!--                                      @change="computeFjsy5(1, 5)"-->
            <!--                                      @keydown.native="handleKeyDown($event, 6, 1)"-->
            <!--                                      @paste.native="handlePasteThree($event, 4, 1)"-->
            <!--                                      :ref="'6_1'"/>-->
            <!--                        </td>-->
            <!--                        <td colspan="1" width="10%">{{ form.fenjsyGroup1Item5 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.leijsyGroup1Item5 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.tonggbflGroup1Item5 }}</td>-->
            <!--                        <td colspan="1" width="10%">-->
            <!--                            <el-input :type="isPdf ? 'string' : 'number'"-->
            <!--                                      v-model="form.shaiszGroup2Item5"-->
            <!--                                      @change="computeFjsy5(2, 5)"-->
            <!--                                      @keydown.native="handleKeyDown($event, 6, 2)"-->
            <!--                                      @paste.native="handlePasteThree($event, 4, 2)"-->
            <!--                                      :ref="'6_2'"/>-->
            <!--                        </td>-->
            <!--                        <td colspan="1" width="10%">{{ form.fenjsyGroup2Item5 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.leijsyGroup2Item5 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.tonggbflGroup2Item5 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.tonggbflPjzItem5 }}</td>-->
            <!--                    </tr>-->
            <!--                    <tr height="50">-->
            <!--                        <td colspan="1" width="10%">-->
            <!--                            <el-input :type="isPdf ? 'string' : 'number'"-->
            <!--                                      v-model="form.shaikccItem6"-->
            <!--                                      @keydown.native="handleKeyDown($event, 7, 0)"-->
            <!--                                      @paste.native="handlePasteThree($event, 5, 0)"-->
            <!--                                      :ref="'7_0'"/>-->
            <!--                        </td>-->
            <!--                        <td colspan="1" width="10%">-->
            <!--                            <el-input :type="isPdf ? 'string' : 'number'"-->
            <!--                                      v-model="form.shaiszGroup1Item6"-->
            <!--                                      @change="computeFjsy6(1, 6)"-->
            <!--                                      @keydown.native="handleKeyDown($event, 7, 1)"-->
            <!--                                      @paste.native="handlePasteThree($event, 5, 1)"-->
            <!--                                      :ref="'7_1'"/>-->
            <!--                        </td>-->
            <!--                        <td colspan="1" width="10%">{{ form.fenjsyGroup1Item6 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.leijsyGroup1Item6 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.tonggbflGroup1Item6 }}</td>-->
            <!--                        <td colspan="1" width="10%">-->
            <!--                            <el-input :type="isPdf ? 'string' : 'number'"-->
            <!--                                      v-model="form.shaiszGroup2Item6"-->
            <!--                                      @change="computeFjsy6(2, 6)"-->
            <!--                                      @keydown.native="handleKeyDown($event, 7, 2)"-->
            <!--                                      @paste.native="handlePasteThree($event, 5, 2)"-->
            <!--                                      :ref="'7_2'"/>-->
            <!--                        </td>-->
            <!--                        <td colspan="1" width="10%">{{ form.fenjsyGroup2Item6 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.leijsyGroup2Item6 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.tonggbflGroup2Item6 }}</td>-->
            <!--                        <td colspan="1" width="10%">{{ form.tonggbflPjzItem6 }}</td>-->
            <!--                    </tr>-->
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="100px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left">
              <!-- {{this.form.jiancr}} -->
            </td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left">
              <!-- {{this.form.jilr}} -->
            </td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%">
              <!-- {{this.form.fuhr}} -->
            </td>
            <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-right: 30px">年</div>
              <div style="display: inline-block; margin-right: 30px">月</div>
              <div style="display: inline-block">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
  </div>
</template>

<script>
import decimal from "@/utils/big-decimal";
import { handleFocus, emptyConvert, handleKeyDown, handlePaste } from "@/views/reportForms/utils";
import Bus from "@/utils/bus";
import { getKfsfsysxfjlbBsInfo } from "@/api/report_jl/kf";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";

export default {
  name: "kfsfsysxfjlbTable",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      form: {
        detailList: [],
        baobbhList: []
      },
      backBgz: {},
      show: false,
      showQyxx: false
    };
  },

  watch: {
    isPdf(newVal, oldVal) {
      this.form = { ...emptyConvert(this.form, newVal) };
    },
    backBgz: {
      deep: true,
      immediate: true,
      handler(newVal, oldVal) {
        this.backBgzFun();
      }
    }
  },
  created() {
    this.init();
  },
  methods: {
    // 根据报表id获取当前报表信息
    init() {
      this.show = false;
      // if (!this.excelId) {
      //     const {jiancdwmc, gongcmc} = this.$store.state.dept.deptInfo;
      //     this.form.jiancdwmc = jiancdwmc;
      //     this.form.gongcmc = gongcmc;
      //     this.form.fujsm = "附加声明：";
      //     return;
      // }
      getKfsfsysxfjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        this.setInitialValue();
        this.show = true;
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
      });
    },
    // 设置初始值
    setInitialValue() {
      if (this.form) {
        this.form.baobmc = this.form.baobmc || "填料筛分试验检测记录表（水洗法）";
        this.form.baobbh = this.form.baobbh || "JGLQ02026a";
        this.$set(this.form, "baobbhList", []);
        this.form.baobbhList = ["JGLQ02026a"];
        this.form.chenglcsItem1 = "1";
        this.form.chenglcsItem2 = "2";
        this.form.chenglcsItem3 = "3";
      }
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setKfBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },
    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
      if (!this.form.pandyj) {
        this.form.pandyj = info.label;
        return;
      }
      if (info && info.label) {
        this.form.pandyj += "、" + info.label;
      }
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setKfBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },
    // 返回报告引入值
    backBgzFun() {},
    submitForm() {
      return this.form;
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    // 试样质量变化
    shiyzlChange(group) {
      if (group == 1) {
        this.computeFjsy1(1, 1);
        this.computeFjsy2(1, 2);
        this.computeFjsy3(1, 3);
        this.computeFjsy4(1, 4);
        this.computeFjsy5(1, 5);
        this.computeFjsy6(1, 6);
      }
      if (group == 2) {
        this.computeFjsy1(2, 1);
        this.computeFjsy2(2, 2);
        this.computeFjsy3(2, 3);
        this.computeFjsy4(2, 4);
        this.computeFjsy5(2, 5);
        this.computeFjsy6(2, 6);
      }
    },
    // 筛上重行1
    computeFjsy1(group, item) {
      if (this.form["shaiszGroup" + group + "Item" + item] && this.form["shiyzlGroup" + group] && this.form["shiyzlGroup" + group] != 0) {
        const a = decimal.multiply(100, this.form["shaiszGroup" + group + "Item" + item] || 0);
        const b = decimal.divide(a, this.form["shiyzlGroup" + group], 1);
        const c = decimal.subtract(100, b, 1);
        this.form["fenjsyGroup" + group + "Item" + item] = b;
        this.form["leijsyGroup" + group + "Item" + item] = b;
        this.form["tonggbflGroup" + group + "Item" + item] = c;
      } else {
        this.form["fenjsyGroup" + group + "Item" + item] = null;
        this.form["leijsyGroup" + group + "Item" + item] = null;
        this.form["tonggbflGroup" + group + "Item" + item] = null;
      }
      this.fjsyPjz(1, 1, 2, 1);
    },
    // 筛上重行2
    computeFjsy2(group, item) {
      if (this.form["shaiszGroup" + group + "Item" + item] && this.form["shiyzlGroup" + group] && this.form["shiyzlGroup" + group] != 0) {
        const a = decimal.multiply(100, this.form["shaiszGroup" + group + "Item" + item] || 0);
        const b = decimal.divide(a, this.form["shiyzlGroup" + item], 1);
        const c = decimal.add(b, this.form.leijsyGroup1Item1, 1);
        const d = decimal.subtract(100, c, 1);
        this.form["fenjsyGroup" + group + "Item" + item] = b;
        this.form["leijsyGroup" + group + "Item" + item] = c;
        this.form["tonggbflGroup" + group + "Item" + item] = d;
      } else {
        this.form["fenjsyGroup" + group + "Item" + item] = null;
        this.form["leijsyGroup" + group + "Item" + item] = null;
        this.form["tonggbflGroup" + group + "Item" + item] = null;
      }
      this.fjsyPjz(1, 2, 2, 2);
    },
    // 筛上重行3
    computeFjsy3(group, item) {
      if (this.form["shaiszGroup" + group + "Item" + item] && this.form["shiyzlGroup" + group] && this.form["shiyzlGroup" + group] != 0) {
        const a = decimal.multiply(100, this.form["shaiszGroup" + group + "Item" + item] || 0);
        const b = decimal.divide(a, this.form["shiyzlGroup" + group], 1);
        const c = decimal.add(b, this.form.leijsyGroup1Item2, 1);
        const d = decimal.subtract(100, c, 1);
        this.form["fenjsyGroup" + group + "Item" + item] = b;
        this.form["leijsyGroup" + group + "Item" + item] = c;
        this.form["tonggbflGroup" + group + "Item" + item] = d;
      } else {
        this.form["fenjsyGroup" + group + "Item" + item] = null;
        this.form["leijsyGroup" + group + "Item" + item] = null;
        this.form["tonggbflGroup" + group + "Item" + item] = null;
      }
      this.fjsyPjz(1, 3, 2, 3);
    },
    // 筛上重行4
    computeFjsy4(group, item) {
      if (this.form["shaiszGroup" + group + "Item" + item] && this.form["shiyzlGroup" + group] && this.form["shiyzlGroup" + group] != 0) {
        const a = decimal.multiply(100, this.form["shaiszGroup" + group + "Item" + item] || 0);
        const b = decimal.divide(a, this.form["shiyzlGroup" + group], 1);
        const c = decimal.add(b, this.form.leijsyGroup1Item3, 1);
        const d = decimal.subtract(100, c, 1);
        this.form["fenjsyGroup" + group + "Item" + item] = b;
        this.form["leijsyGroup" + group + "Item" + item] = c;
        this.form["tonggbflGroup" + group + "Item" + item] = d;
      } else {
        this.form["fenjsyGroup" + group + "Item" + item] = null;
        this.form["leijsyGroup" + group + "Item" + item] = null;
        this.form["tonggbflGroup" + group + "Item" + item] = null;
      }
      this.fjsyPjz(1, 4, 2, 4);
    },
    // 筛上重行5
    computeFjsy5(group, item) {
      if (this.form["shaiszGroup" + group + "Item" + item] && this.form["shiyzlGroup" + group] && this.form["shiyzlGroup" + group] != 0) {
        const a = decimal.multiply(100, this.form["shaiszGroup" + group + "Item" + item] || 0);
        const b = decimal.divide(a, this.form["shiyzlGroup" + group], 1);
        const c = decimal.add(b, this.form.leijsyGroup1Item4, 1);
        const d = decimal.subtract(100, c, 1);
        this.form["fenjsyGroup" + group + "Item" + item] = b;
        this.form["leijsyGroup" + group + "Item" + item] = c;
        this.form["tonggbflGroup" + group + "Item" + item] = d;
      } else {
        this.form["fenjsyGroup" + group + "Item" + item] = null;
        this.form["leijsyGroup" + group + "Item" + item] = null;
        this.form["tonggbflGroup" + group + "Item" + item] = null;
      }
      this.fjsyPjz(1, 5, 2, 5);
    },
    // 筛上重行6
    computeFjsy6(group, item) {
      if (this.form["shaiszGroup" + group + "Item" + item] && this.form["shiyzlGroup" + group] && this.form["shiyzlGroup" + group] != 0) {
        const a = decimal.multiply(100, this.form["shaiszGroup" + group + "Item" + item] || 0);
        const b = decimal.divide(a, this.form["shiyzlGroup" + group], 1);
        const c = decimal.add(b, this.form.leijsyGroup1Item5, 1);
        const d = decimal.subtract(100, c, 1);
        this.form["fenjsyGroup" + group + "Item" + item] = b;
        this.form["leijsyGroup" + group + "Item" + item] = c;
        this.form["tonggbflGroup" + group + "Item" + item] = d;
      } else {
        this.form["fenjsyGroup" + group + "Item" + item] = null;
        this.form["leijsyGroup" + group + "Item" + item] = null;
        this.form["tonggbflGroup" + group + "Item" + item] = null;
      }
      this.fjsyPjz(1, 6, 2, 6);
    },
    // 求平均值
    fjsyPjz(g1, t1, g2, t2) {
      if (this.form["tonggbflGroup" + g1 + "Item" + t1] && this.form["tonggbflGroup" + g2 + "Item" + t2]) {
        const e = decimal.add(this.form["tonggbflGroup" + g1 + "Item" + t1], this.form["tonggbflGroup" + g2 + "Item" + t2]);
        const f = decimal.divide(e, 2, 1);
        this.form["tonggbflPjzItem" + t1] = f;
      } else {
        this.form["tonggbflPjzItem" + t1] = null;
      }
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [2, 1, 2, 2, 2, 2, 2, 2]; // 每一行最多有多少可聚焦输入框（从0开始）
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    },
    // 粘贴赋值方法
    handlePaste(event, rowIndex, colIndex) {
      const nameAllArr = [["shiyzbzlItem1", "shiyzbzlItem2", "shiyzbzlItem3"]];
      const subscriptArr = [[0, 1, 2]];

      const methodsAllArr = [];
      const parameterArr = [];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
          }
        }
      }
    },

    // 粘贴赋值方法
    handlePasteTwo(event, rowIndex, colIndex) {
      const nameAllArr = [["shiyzlGroup1", "shiyzlGroup2"]];
      const subscriptArr = [[0, 1]];

      const methodsAllArr = [["shiyzlChange", "shiyzlChange"]];
      const parameterArr = [[1, 2]];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
          }
        }
      }
    },

    // 粘贴赋值方法
    handlePasteThree(event, rowIndex, colIndex) {
      const nameAllArr = [
        ["shaikccItem1", "shaiszGroup1Item1", "shaiszGroup2Item1"],
        ["shaikccItem2", "shaiszGroup1Item2", "shaiszGroup2Item2"],
        ["shaikccItem3", "shaiszGroup1Item3", "shaiszGroup2Item3"],
        ["shaikccItem4", "shaiszGroup1Item4", "shaiszGroup2Item4"],
        ["shaikccItem5", "shaiszGroup1Item5", "shaiszGroup2Item5"],
        ["shaikccItem6", "shaiszGroup1Item6", "shaiszGroup2Item6"]
      ];
      const subscriptArr = [
        [0, 1, 2],
        [0, 1, 2],
        [0, 1, 2],
        [0, 1, 2],
        [0, 1, 2],
        [0, 1, 2]
      ];

      const methodsAllArr = [
        [null, "computeFjsy1", "computeFjsy1"],
        [null, "computeFjsy2", "computeFjsy2"],
        [null, "computeFjsy3", "computeFjsy3"],
        [null, "computeFjsy4", "computeFjsy4"],
        [null, "computeFjsy5", "computeFjsy5"],
        [null, "computeFjsy6", "computeFjsy6"]
      ];
      const parameterArr = [
        [null, "1-1", "2-1"],
        [null, "1-2", "2-2"],
        [null, "1-3", "2-3"],
        [null, "1-4", "2-4"],
        [null, "1-5", "2-5"],
        [null, "1-6", "2-6"]
      ];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            let parameter = parameterSetArr[a][b];
            let parameterArr = parameter ? parameter.split("-") : [];
            if (parameterArr.length >= 2) {
              this.setCalculate(methodsSetArr[a][b], parameterArr[0], parameterArr[1]);
            }
          }
        }
      }
    },

    // 计算方法调用
    setCalculate(name, a, b, c, d, e) {
      this[name](a, b, c, d, e);
    }
  }
};
</script>

<style scoped lang="scss">
// .a{width: calc();}
</style>
